#include "textButton.h"
#include "util.h"
#include "global.h"
#include <string.h>
void TextButton_show(SDL_Renderer *renderer, TextButton *textButton,TTF_Font *font, TextTexture *textTexture)
{
    SDL_SetRenderDrawColor(renderer, textButton->color.r, textButton->color.g, textButton->color.b, textButton->color.a);
    SDL_RenderFillRect(renderer, &textButton->rect);
    textTexture->drawText(renderer, textTexture, font, textButton->text, textButton->rect.x+FONT_SIZE/2, textButton->rect.y+FONT_SIZE/2, 1.0f, textTexture->defaultColor);

}
void TextButton_setClickEvent(TextButton *textButton, void (*func))
{
}
void TextButton_clickEvent()
{
}

void TextButton_init(TextButton *self, const char *name,const char *text, SDL_Rect rect, SDL_bool enabled, SDL_KeyCode bindKey, SDL_Color color, SDL_Color textColor)
{
    size_t len = strlen(name);
    self->name =malloc(len + 1);
    memcpy(self->name, name, len);
    self->name[len] = '\0';
    size_t len2 = strlen(text);
    self->text = malloc(len + 1);
    memcpy(self->text, text, len2);
    self->text[len2] = '\0';
    self->rect = rect;
    self->enabled = enabled;
    self->bindKey = bindKey;
    self->color =color;
    self->textColor = textColor;
}
CTOR(TextButton)
FUNCTION_SETTING(show,TextButton_show);
FUNCTION_SETTING(init,TextButton_init);
FUNCTION_SETTING(setClickEvent,TextButton_setClickEvent);
FUNCTION_SETTING(clickEvent,TextButton_clickEvent);

END_CTOR